package org.helsoft.mojo;

import java.io.File;
import java.io.IOException;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.FileUtils;
import org.helsoft.mojo.api.PDEMojo;

/**
 * 
 * @author hesteguet
 * @goal clean
 * 
 * @phase clean
 */
public class CleanMojo extends PDEMojo {

	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {
		File dir = getLibrairiesLocation();
		if (dir != null) {
			try {
				FileUtils.deleteDirectory(dir);
			} catch (IOException e) {
				fail(e.getMessage(), e);
			}
		}
		
		if(pdePOMFile != null && !"pom.xml".equals(pdePOMFile.getName())) {
			pdePOMFile.delete();
		}
	}
	
}
